package com;

import java.io.IOException;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.RequestEntity;

public class HttpRequest {

//	static {
//		@SuppressWarnings("deprecation")
//		
//    }
	 /** 
     * @param args 
     * @throws IOException  
     * @throws ClientProtocolException  
     */  
    public static void main(String[] args) throws  IOException  
    {  
        HttpClient httpclient = new HttpClient();  
        PostMethod method = new PostMethod("http://127.0.0.1:8888/");
    	NameValuePair param = new NameValuePair("username", "zhangli");
    	method.setQueryString(new NameValuePair[]{param});
    	RequestEntity entity = new ByteArrayRequestEntity("zhangli".getBytes());
    	method.setRequestEntity(entity);
    	httpclient.executeMethod(method);
    	String ss = method.getResponseBodyAsString();
    	System.out.println(ss);
    	method.releaseConnection();
    	//method.setr
        /*Protocol myhttps = new Protocol("https", new HttpsSecureProtocolSocketFactory(), 443);
		Protocol.registerProtocol("https", myhttps);
    	HttpMethod method = new PostMethod("https://localhost:8080/aa/23/2016/bb");
    	method.getResponseBodyAsStream();
    	httpclient.executeMethod(method);
    	method.getResponseBodyAsStream();
    	method.releaseConnection();*/
    }  
}
